import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {path: '/',name: 'QUAN',redirect:'/login'},
  {path: '/login',name: 'Login',component: ()=>import('../views/Login')},
  {path: '/register',name: 'Register',component: () => import('../views/Register.vue')},
  // {path: '/index',name: 'Index',component: () => import('../views/Index.vue')},
  {path: '/botnav',name: 'Botnav',redirect:'/botnav/index',component: () => import('../views/Botnav.vue'),children:[
    {path: 'index',name: 'Index',component: () => import('../views/Index.vue')},
    {path: 'list',name: 'List',component: () => import('../views/List.vue')},
    {path: 'search',name: 'Search',component: () => import('../views/Search.vue')},
    {path: 'cart',name: 'Cart',meta:{requireAuth:true}, component: () => import('../views/Cart.vue')},
    {path: 'mine',name: 'Mine',meta:{requireAuth:true}, component: () => import('../views/Mine.vue')},
    // meta:{requireAuth:true}//当有这个字段的时候，我们就认为他这个路由页面是要有登录权限的
  ]},
]

const router = new VueRouter({
  routes,
  mode:'history'
})

export default router
